public class Node(){
    public int value;
    public Node next;
    public Node(int data){
        this.value=data;
    }
}

public boolean isPalindrome2(Node head){
    if(head==null||head.next==null){
        return true;
    }
    Node right=head.next;
    Node next=head;
    while(cur.next!=null&&cur.next.next!=null){
        right=right.next;
        cur=cur.next.next;
    }
    
    Stack<Node> stack=new Stack<>();
    while(right!=null){
        stack.push(right);
        right=right.next;
    }

   while(!stack.isEmpty()){
       if(head.value!=stack.pop().value){
           return false;
       }head=head.next;

   }return true;

}